<template>
    <div>
        <el-form ref="userBaseInfo" :model="baseUserInfo" label-width="120px" size="medium" :rules="rules">
            <el-form-item label="姓名" prop="nickName">
                <el-input v-model="baseUserInfo.nickName"></el-input>
            </el-form-item>
            <el-form-item label="手机号" prop="phone">
                <el-input v-model="baseUserInfo.phone"></el-input>
            </el-form-item>
            <el-form-item label="联系邮箱" prop="email">
                <el-input v-model="baseUserInfo.email"></el-input>
            </el-form-item>
            <el-form-item label="身份证" prop="cardCode">
                <el-input v-model="baseUserInfo.cardCode"></el-input>
            </el-form-item>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="身份证(人像面)" prop="cardUrl1">
                        <fileUpload url="/common/upload/fileUpload/" v-model="baseUserInfo.cardUrl1" :width="360"
                            :height="230" :file-number="1" :init-images="[baseUserInfo.cardUrl1]"/>
                    </el-form-item>
                </el-col>

                <el-col :span="12">
                    <el-form-item label="身份证(国徽面)" prop="cardUrl2">
                        <fileUpload url="/common/upload/fileUpload/" v-model="baseUserInfo.cardUrl2" :width="360"
                            :height="230" :file-number="1" :init-images="[baseUserInfo.cardUrl2]"/>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item>
                <el-button type="primary" @click="updateSave" style="margin-top:30px">修改保存</el-button>
            </el-form-item>

        </el-form>
    </div>
</template>



<script>
import fileUpload from '@/components/common/fileUpload/fileUpload.vue';
import { updateUserBaseInfo } from '@/api/system/userApi'
export default {
    components: { fileUpload },
    props: {
        baseUserInfo: {
            type: Object,
            required: true
        },
        rules: {
            type: Object,
            required: true
        }
    },
    methods: {
        //更新保存执行
        updateSave() {
            this.$refs.userBaseInfo.validate(valid => {
                if (valid) {
                    updateUserBaseInfo(this.baseUserInfo).then(data => {
                        this.$message.success("修改成功");
                    }).catch(err => {
                        this.$message.error(err);
                    })
                } else {
                    return false;
                }
            })


        }
    },
}

</script>


<style scoped lang="scss"></style>